package com.ddone.demo.bean;

import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
import com.alibaba.excel.annotation.ExcelProperty;
import com.alibaba.excel.annotation.format.DateTimeFormat;
import com.alibaba.excel.annotation.format.NumberFormat;
import com.alibaba.excel.annotation.write.style.*;
import com.alibaba.excel.enums.poi.BorderStyleEnum;
import com.alibaba.excel.enums.poi.FillPatternTypeEnum;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.apache.poi.ss.usermodel.IndexedColors;

import java.util.Date;

/**
 * @author ddone
 * @date 2024/4/12-17:00
 */
@Data
@Builder
@HeadRowHeight(value = 30)
@ExcelIgnoreUnannotated // 只导出带有ExcelProperty注解的字段
// 指定行高
//设置表头除了单元格文本外其他的样式
@HeadStyle(leftBorderColor = 13 ,borderLeft = BorderStyleEnum.THIN,
        rightBorderColor = 13 , borderRight = BorderStyleEnum.MEDIUM_DASH_DOT,
        //背景颜色 和填充方式
        fillForegroundColor =17 , fillPatternType = FillPatternTypeEnum.SOLID_FOREGROUND)
@AllArgsConstructor
@NoArgsConstructor
public class Teacher {
    //value映射到excel中的表头名称   index：写入到excel中的索引从0开始
    @ExcelProperty(value = "编号",index = 3)
    private Integer id;

    @ExcelProperty(value = "姓名")
    private String name;

    @ExcelProperty(value = "年龄")
    private Integer age;

    @ExcelProperty(value = "月薪")
    //数值格式化 //小数点后的#个数表示精确到小数点后的位数
    @NumberFormat(value = "#.##")
    private  Double salary;

    @ExcelProperty(value = "入职时间")
    //时间日期格式化
    @DateTimeFormat(value = "yyyy年MM月dd日 HH:mm:ss")
    private Date joinDate;

    @ColumnWidth(value= 30) //指定当前列的宽度
    @ContentStyle(fillForegroundColor = 40 , fillPatternType = FillPatternTypeEnum.SOLID_FOREGROUND )
    @ContentFontStyle(fontName = "隶书", color = 51)
    private String link;

    @ExcelProperty(value = "个人介绍")
    @ColumnWidth(value = 25)
    private String comment;
}
